import axios from "axios";

const request = axios.create({
    baseURL: "http://localhost:5000",
})

export const get = async (url, params) => {
    const res = await request.get(url, { params })
    return res.data
}

export const post = async (url, data, isBody = false) => {
    const res = await request.post(url, data, {
        headers: {
            'Content-Type': isBody ? 'application/json' : 'x-www-form-urlencoded'
        }
    })
    return res.data
}

export const uploadFile = (url, data = {}) => {
    return request.post(url, data, {
        headers: {
            'Content-Type': 'multipart/form-data',
        },
    });
};

export const post2 = async (url, data) => {
    const res = await request.post(url, data, {
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        }
    });
    return res.data;
}